package partlow.yelp.parsers;

import org.json.JSONException;
import org.json.JSONObject;

import partlow.yelp.datatypes.YelpDealOption;

public class DealOptionParser extends YelpTypeParser<YelpDealOption> {

	@Override
    public YelpDealOption parse(JSONObject json) throws JSONException {
		YelpDealOption obj = new YelpDealOption();
		if(json.has("title"))
            obj.setTitle(json.getString("title"));
		if(json.has("purchase_url"))
            obj.setPurchaseURL(json.getString("purchase_url"));
		if(json.has("remaining_count"))
            obj.setRemainingCount(json.getInt("remaining_count"));
		
		return obj;
	}
}
